package com.electron.power.octopus.service;

import java.time.Duration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import com.electron.power.model.mod.ModBodyMap;
import com.electron.power.octopus.repository.ModBodyMapRepository;

import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Service
@Slf4j
public class ModBodyMapService {
	
	private static final int DELAY_PER_ITEM_MS = 100;
	
	@Autowired
	private ModBodyMapRepository modBodyMapRepository;
	
	
	public Mono<ModBodyMap> add(ModBodyMap mod) {
		return modBodyMapRepository.save(mod);
	}

	public Flux<ModBodyMap> findAll() {
		return modBodyMapRepository.findAll();
	}

	public Flux<ModBodyMap> retrieveAllPaged(int page,int size) {
		return modBodyMapRepository.retrieveAllPaged(PageRequest.of(page, size));
//                .delayElements(Duration.ofMillis(DELAY_PER_ITEM_MS));
	}
}
